/**********************************************************
 * File
 *	inputbox.js
 * Description
 *	Handles the input box dialog.
 *********************************************************/

/*
 * Name: showInputBox()
 * Desc: Displays a dialog box to retrieve input from the user.
 */
badpass.showInputBox = function(title, request) {
	var extraParams = { windowtitle: title, request: request, response: null };
	window.openDialog("chrome://badpass/content/inputbox.xul", "inputbox", "modal=yes,centerscreen", extraParams);
	return extraParams.response;
}

/*
 * Name: onOpenInputBox()
 * Desc: Displays the input box label when opened.
 */
badpass.onOpenInputBox = function() {
	document.title = window.arguments[0].windowtitle;
	var label = document.getElementById("badpass-inputbox-label");
	label.value = window.arguments[0].request;
}

/*
 * Name: onAcceptInputBox()
 * Desc: Returns the input value.
 */
badpass.onAcceptInputBox = function() {
	var textBox = document.getElementById("badpass-inputbox-text");
	if(textBox.value.length > 0) {
		window.arguments[0].response = textBox.value;
		return true;
	} else {
		alert(this.strings.getString("extensions.badpass@nickbloor.co.uk.inputbox.noinput"), this.strings.getString("extensions.badpass@nickbloor.co.uk.inputbox.noinput.title"));
		return false;
	}
}
